<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
    	$map['create_time'] = array('between', array(date("Y-m-d")." 00:00:00", date("Y-m-d")." 23:59:59"));
    	$today_user = M("User")->where($map)->count();
    	$today_wechat = M("Wechat")->where($map)->count();
    	$all_wechat = M("Wechat")->count();
    	$this->assign('today_user',$today_user);
    	$this->assign('today_wechat',$today_wechat);
    	$this->assign('all_wechat',$all_wechat);

     	$this->display();   
    }

    public function edit(){
        $model = M("AdminUser");
        $map['uid'] = 1;

        if(IS_AJAX){
            $new['username'] = I('post.username');
            if(empty($new['username'])){
                $this->error('请输入用户名');
            }
            $new['password'] = I('post.password');
            if(!empty($new['password'])){
                $new['password'] = md5($new['password']);
            }
            $model->where($map)->save($new);
            session(null);
            $this->success('修改成功，请重新登录！');
        }else{
            $vo = $model->where($map)->find();
            $this->assign('vo',$vo);
            $this->display();
        }
    }
}